package com.horse.cloud.framework.base.callback;

import com.horse.cloud.framework.general.response.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @create : Created by intelliJ IDEA 17.2
 * @author : bing.Pan
 * @e-mail : 15923508369@163.com
 * @gmdate : 11 13 2017 14:03
 * @sidesc : 手动事物回调执行方法抽象类，
 */
public abstract class DoTransactionContent<T>{

    protected static final Logger LOGGER = LoggerFactory.getLogger(DoTransactionContent.class);

    public DoTransactionContent(){}

    /**
     * 日志标题
     */
    private String logTitle;

    /**
     * 执行方法
     */
    private String logMethod;

    /**
     * 参数
     */
    private Object requestArgs;



    public void setLogTitle(String logTitle) {
        this.logTitle = logTitle;
    }



    public void setLogMethod(String logMethod) {
        this.logMethod = logMethod;
    }



    public void setRequestArgs(Object requestArgs) {
        this.requestArgs = requestArgs;
    }



    public DoTransactionContent logTitle(String title) {
        setLogTitle(title);
        return this;
    }

    public DoTransactionContent logMethod(String method) {
        setLogMethod(method);
        return this;
    }

    public DoTransactionContent requestArgs(Object... obj) {
        setRequestArgs(obj);
        return this;
    }



    public DoTransactionContent recordTransactionContentLog(){
        LOGGER.info("【framework-base】统一事物执行日志,logTitle[{}]; logMethod[{}]; requestArgs[{}]",logTitle,logMethod, requestArgs);
        return this;
    }


    /**
     * 事物执行抽象类
     * @return
     * @throws Exception
     */
    public abstract Response<T> execute() throws  Exception;

}
